<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    #box{
        width: 100%;
        height: 1200px;
        background-color: rgba(8, 8, 8, 0.5);
        display: none;
    }
    #box1{
        width: 500px;
        height: 400px;
        margin: auto;
        background-color: darkred;
        position: relative;

    }
    p{
        color: aliceblue;
        position: absolute;
        top: -10px;
        right: 3px;
    }
    </style>
</head>
<body>
    <button id="button">弹出层</button>
    <div id="box">
        <div id="box1">
            <p id="xx">X</p>
        </div>
    </div>
</body>
</html>
<script>
    var btn = document.getElementById('button')
    var hz = document.getElementById('box')
    // var hz1 = document.getElementById('box1')
    var x = document.getElementById('xx')
    btn.onclick = function(){
        hz.style.display = 'block'
    }
    x.onclick = function(){
        hz.style.display = 'none'
    }
</script>